
// 汽车生成
public class GenerateCarThread extends Thread {
    @Override
    public void run() {
        int count = 1234;
        while (true) {
            synchronized (Car.getParkingLot()) {
                while (Car.getParkingLot().parkingSpaceNumLeft() == 0) {
                    try {
                        Car.getParkingLot().wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
            Car car = new Car(Integer.toString(count++));
            System.out.println("生产了一辆车");
            car.start();
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }

    }
}
